import { uploadType, getAreaObj } from '@/utils/util'
import {configToSearch,toSearchHandle} from '@/views/datacenter/business/utils/index'

const tableConfig = {
	stripe: true,
	border: true,
	maxHeight: '80vh',
	columns: [
		{
			label: '所属区域',
			prop: 'belongAreaName',
		},
		// {
		// 	label: '统一社会信用代码',
		// 	prop: 'creditCode',
		// 	type: 'input',
		// },
		{
			label: '机构名称',
			prop: 'organizationName',
			type: 'input',
		},
		{
			label: '联系人',
			prop: 'deputyUserName',
			type: 'input',
		},
		{
			label: '联系方式',
			prop: 'organizationPhone',
			type: 'tel',
			plusXing: '5,2'
		},
		{
			label: '申请人数',
			prop: 'applyPeopleTotal',
			type: 'input',
		},
		{
			label: '申请金额',
			prop: 'subsidyTotalAmount',
			type: 'input',
		},
		{
			label: '申报年月',
			prop: 'fillingDate',
			type: 'date',
			format: 'YYYY年MM月DD日',
			valueFormat: 'YYYY-MM-DD',
		},
		{
			label: '是否可信',
			prop: 'isBelievable',
			custome: 'tag',
			dicData: [
				{ label: '否', value: 0,type:'danger' },
				{ label: '是', value: 1,type:'success' },
			],
		},
		{
			label: '操作',
			prop: 'menu',
			width: 300,
			fixed: 'right',
		},
	],
}
export const detailConfig: any = {
	label: '家庭养老床位运营补贴详情',
	prop: 'base1',
	inline: false,
	showBtn: false,
	labelPosition: 'left',
	column: [
		{
			label:'机构ID(统一信用代码)',
			prop:'creditCode'
		},
		{
			label:'补贴唯一值',
			prop:'soleValue'
		},
		{
			label:'机构基本情况-机构名称',prop:'organizationName',
			type: 'text',
			maxlength: '50',
			showWordLimit: true,
		},
		{
			label:'机构基本情况-机构地址',prop:'organizationAddress',
			type: 'text',
			maxlength: '140',
			showWordLimit: true,
		},
		{
			label:'所属区划',
			prop:'belogArea',
			type:'AplidAreaSelect'
		},
		{
			label:'机构基本情况-机构等级',
			prop:'organizationLevel',
			proName:'organizationLevelLabel',
			api:'getDictItemList',
			code:"ORG_LEVEL",
			type:"remoteSelect"
		},
		{
			label:"机构基本情况-法定代表人姓名",
			prop:"deputyUserName",
			type: 'text',
			maxlength: '20',
			showWordLimit: true,
		},
		{
			label:"机构基本情况-机构电话",
			prop:"organizationPhone",
			type: 'text',
			maxlength: '11',
			showWordLimit: true,
		},
		{
			label:"机构基本情况-开户银行",
			prop:"bankName",
			type: 'text',
			maxlength: '50',
			showWordLimit: true,
		},
		{
			label:"机构基本情况-银行账号",
			prop:"bankAccount",
			type: 'text',
			maxlength: '50',
			showWordLimit: true,
		},
		{
			label:"机构基本情况-核定床位数(张)",
			append:'张',
			prop:"realBedNum"
		},
		{
			label:"入住老人数",
			append:"人",
			prop:"checkinOldmanNum"
		},
		{
			label:'机构基本情况-营业执照(民非)证号',
			prop:"organizationLicense",
			type: 'text',
			maxlength: '50',
			showWordLimit: true,
		},
		{
			label:'机构基本情况-机构设置证号(备案)',
			prop:"organizationFiling",
			type: 'text',
			maxlength: '50',
			showWordLimit: true,
		},
		{
			label:'养老机构服务质量大检查指南基础指标是否全部达标',
			prop:"baseQualityStandard",
			propName:"baseQualityStandardLabel",
			api:'getDictItemList',
			code:"COMMON_FLAG",
			type:"remoteSelect"
		},
		{
			label:'员工概括-员工总数',
			prop:"staffNum",
			append:"人",
		},
		{
			label:'员工概括-持证员工人数',
			prop:"certStaffNum",
			append:"人",
		},
		{
			label:'员工概括-管理人员数量',
			prop:"managerNum",
			append:"人",
		},
		{
			label:'员工概括-持证管理人员数',
			prop:"certManagerNum",
			append:"人",
		},
		{
			label:'申请年份',
			prop:"applyYear",
		},
		{
			label:'申请年份季度',
			prop:'applyYearQuarter',
			propName:"applyYearQuarterLabel",
			api:'getDictItemList',
			code:"QUARTER",
			type:"remoteSelect"
		},
		{
			label:"申请内容-总计",
			prop:"applyContentAmount",
			append:'人'
		},
		{
			label:"申请内容-其中不符合补贴条件",
			prop:"unconformityNum",
			append:'人'
		},
		{
			label:"申请内容-其中未满60周岁",
			prop:"lessSixtyNum",
			append:'人'
		},
		{
			label:"申请内容-政府供养",
			prop:"govSupportNum",
			append:'人'
		},
		{
			label:"申请内容-补贴金额(小写)",
			prop:"subsidyTotalAmount",
			append:'元'
		},
		{
			label:"申请内容-补贴金额(大写)",
			prop:"subsidyTotalAmountText",
			type: 'text',
			maxlength: '140',
			showWordLimit: true,
		},
		{
			label:"申请内容-申报负责人姓名",
			prop:"fillingUserName",
			type: 'text',
			maxlength: '20',
			showWordLimit: true,
		},
		{
			label:"申请内容-申报日期",
			prop:"fillingDate",
			type:'date',
			format:"YYYY年MM月DD日",
			valueFormat:"YYYY-MM-DD"
		},
		
		{
			label:"申请内容-区民政部门审核意见",
			prop:"approvalCivilAffairNote",
			type: 'text',
			maxlength: '140',
			showWordLimit: true,
		},
		{
			label:"申请内容-区民政部门审核日期",
			prop:"approvalCivilAffairDate",
			type:'date',
			format:"YYYY年MM月DD日",
			valueFormat:"YYYY-MM-DD"
		},
		{
			label:"自查时间",
			prop:"selfCheckDate",
			type:'date',
			format:"YYYY年MM月DD日",
			valueFormat:"YYYY-MM-DD"
		},
		{
			label:"自查方式",
			prop:"selfCheckWay",
			type: 'text',
			maxlength: '140',
			showWordLimit: true,
		},
		{
			label:'参与人数',
			prop:"partakeNum",
			append:'人'
		},
		{
			label:'参与比例',
			prop:"partakeRate",
			append:'百分比'
		},
		{
			label:"是否存在虚假广告宣传",
			prop:'unrealPublicityFlag',
			propName:"unrealPublicityFlagLabel",
			api:'getDictItemList',
			code:"COMMON_FLAG",
			type:"remoteSelect"
		},
		{
			label:'是否存在虚假广告宣传备注',
			prop:"unrealPublicityNote",
			type: 'text',
			maxlength: '140',
			showWordLimit: true,
		},
		{
			label:'是否按照协议提供服务',
			prop:'agreementServiceFlag',
			propName:"agreementServiceFlagLabel",
			api:'getDictItemList',
			code:"COMMON_FLAG",
			type:"remoteSelect"
		},
		{
			label:'是否按照协议提供服务备注',
			prop:"agreementServiceNote",
			type: 'text',
			maxlength: '140',
			showWordLimit: true,
		},
		{
			label:"是否侵害老人合法权益",
			prop:"infringementFlag",
			propName:"infringementFlagLabel",
			api:'getDictItemList',
			code:"COMMON_FLAG",
			type:"remoteSelect"
		},
		{
			label:"是否侵害老人合法权益备注",
			prop:"infringementNote",
			type: 'text',
			maxlength: '140',
			showWordLimit: true,
		},
		
		{
			label:"老人对机构的综合评价",
			prop:"comprehensiveEvaluation",
			propName:"comprehensiveEvaluationLabel",
			api:'getDictItemList',
			code:"EVALUATION",
			type:"remoteSelect"
		},
		
		{
			label:"其他事项",
			prop:"otherThings",
			type: 'text',
			maxlength: '140',
			showWordLimit: true,
		},
		{
			label:"自查结论",
			prop:"selfCheckResult",
			propName:"selfCheckResultLabel",
			api:'getDictItemList',
			code:"EVALUATION",
			type:"remoteSelect"
		},
		{
			label:"自查结论满意率",
			prop:"selfCheckSatisfyRate",
			append:'百分比'
		},
		{
			label:'自查情况-评定负责人',
			prop:"evaluatorName",
			type: 'text',
			maxlength: '20',
			showWordLimit: true,
		},
		{
			label:'自查情况-评定日期',
			prop:"estimateDate",
			type:'date',
			format:"YYYY年MM月DD日",
			valueFormat:"YYYY-MM-DD"
		},
		{
			label:'区民政局委托的第三方专业机构出具的老年人能力评估表',
			prop:"thirdAbilityFiles",
			type:'upload'
		},
		{
			label:'南京市家庭养老床位认定评估报告',
			prop:"homeBedAssessFiles",
			type:"upload"
		}
	],
}
const moreSearchConfig:any = {
	inline: true,
	showBtn: false,
	labelPosition: 'left',
	column:[
		...configToSearch(detailConfig.column)
	]
}
const importConfig = {
	tabSteps: [
		{
			label: '下载模板',
			download: '下载模板',
			active: 1,
			rules: [
				{
					label: '下载最新导入模板。共2个：',
					children: [
						{
							label: '《家庭养老床位运营补贴信息表》',
							link: true,
							url: 'dpHomeBedSubsidy_downloadTemplate',
						},
						{
							label: '《家庭养老床位运营补贴花名册信息表》',
							link: true,
							url: 'dpHomeBedSubsidyRoster_downloadTemplate',
						},

						{
							label: '《家庭养老床位运营补贴-申请内容》',
							link: true,
							url: 'view_dpHomeBedApply_downloadTemplate',
						},
						{
							label: '《家庭养老床位运营补贴-调查人信息》',
							link: true,
							url: 'view_dpHomeBedInvestigator_downloadTemplate',
						},
						{
							label: '《家庭养老床位运营补贴-自查情况-存在的问题》',
							link: true,
							url: 'view_dpHomeBedQuestion_downloadTemplate',
						},
					],
				},
			],
		},
		{
			label: '导入《家庭养老床位运营补贴信息表》',
			description: '',
			uploadTip: '家庭养老床位运营补贴信息表',
			active: 2,
			url: 'dpHomeBedSubsidy_import',
			code: 3033,
			rules: [
				{
					label: '导入规则说明:',
					children: [
						{
							label: '(1)导入模式为“覆盖导入”，待导入的家庭养老床位运营补贴信息会覆盖平台已存在的',
						},
					],
				},
			],
		},
		{
			label: '导入《家庭养老床位运营补贴花名册信息表》',
			description: '',
			uploadTip: '家庭养老床位运营补贴花名册信息表',
			active: 3,
			url: 'dpHomeBedSubsidyRoster_import',
			code: 3034,
			rules: [
				{
					label: '导入规则说明:',
					children: [
						{
							label: '(1)导入模式为“覆盖导入”，待导入的家庭养老床位运营补贴花名册信息会覆盖平台已存在的',
						},
					],
				},
			],
		},
		{
			label: '导入《家庭养老床位运营补贴-申请内容》',
			description: '',
			uploadTip: '家庭养老床位运营补贴-申请内容信息表',
			active: 4,
			url: 'view_dpHomeBedApply_import',
			code: 3101,
			rules: [
				{
					label: '导入规则说明:',
					children: [
						{
							label: '(1)导入模式为“覆盖导入”，待导入的家庭养老床位运营补贴-申请内容信息会覆盖平台已存在的',
						},
					],
				},
			],
		},
		{
			label: '导入《家庭养老床位运营补贴-调查人信息》',
			description: '',
			uploadTip: '家庭养老床位运营补贴-调查人信息表',
			active: 5,
			url: 'view_dpHomeBedInvestigator_import',
			code: 3102,
			rules: [
				{
					label: '导入规则说明:',
					children: [
						{
							label: '(1)导入模式为“覆盖导入”，待导入的家庭养老床位运营补贴-调查人信息会覆盖平台已存在的',
						},
					],
				},
			],
		},
		{
			label: '导入《家庭养老床位运营补贴-自查情况-存在的问题》',
			description: '',
			uploadTip: '家庭养老床位运营补贴-自查情况-存在的问题信息表',
			active: 6,
			url: 'view_dpHomeBedQuestion_import',
			code: 3103,
			rules: [
				{
					label: '导入规则说明:',
					children: [
						{
							label: '(1)导入模式为“覆盖导入”，待导入的家庭养老床位运营补贴-自查情况-存在的问题信息会覆盖平台已存在的',
						},
					],
				},
			],
		},
	],
}
export const baseConfig: any = {
	pageName: '家庭养老床位运营补贴',
	dictcodes: ['SUBSIDY_APPLICATION_DISBURSEMENT_TYPE','DUTIES_TYPE','EVALUATION','ORG_LEVEL','COMMON_FLAG','QUARTER'],
	rowKey: 'id',
	tipLabel: 'organizationName',
	// exportMqTopic: '/ning/export',
	exportMqTopic: [
		{
			topic: '/ning/export/dpHomeBedApply/',
			label: '家庭养老床位运营补贴-申请内容',
			code: 3101,
			po: 'dpHomeBedApplyPO',
		},
		{
			topic: '/ning/export/dpHomeBedInvestigator/',
			label: '家庭养老床位运营补贴-调查人信息',
			code: 3102,
			po: 'dpHomeBedInvestigatorPO',
		},
		{
			topic: '/ning/export/dpHomeBedQuestion/',
			label: '家庭养老床位运营补贴-自查情况-存在的问题',
			code: 3103,
			po: 'dpHomeBedQuestionPO',
		},
		{
			topic: '/ning/export/dpHomeBedSubsidy/',
			label: '家庭养老床位运营补贴信息',
			code: 3033,
			po: 'dpHomeBedSubsidyPO',
		},
		{
			topic: '/ning/export/dpHomeBedSubsidyRoster/',
			label: '家庭养老床位运营补贴花名册',
			code: 3034,
			po: 'dpHomeBedSubsidyRosterPO',
		},
	],
	api: {
		moreSearch:'view_dpHomeBedSubsidy_search',
		index: 'dpHomeBedSubsidy_page',
		delete: 'dpHomeBedSubsidy_del',
		export: 'view_dpHomeBedSubsidy_exportAll',
		import: 'dpHomeBedSubsidy_import',
	},
	auth: {
		index: 'view_dpHomeBedSubsidy_page',
		mulitSet: 'mulitSet',
		delete: 'view_dpHomeBedSubsidy_del',
		// export: 'view_dpHomeBedSubsidy_exportAll',
		// import: 'view_dpHomeBedSubsidy_import',
	},
	menuBtn: [
		{
			icon: 'editor',
			label: '查看详情',
			type: 'primary',
			operate: 'Detail',
			auth: '',
			text: true,
			show: true,
		},
	],
	dialogConfig: {
		width: '65%',
	},
	moreSearchConfig,
	searchConfig: {
		inline: true,
		showBtn: true,
		labelPosition: 'left',
		column: [
			{
				label: '信用代码',
				prop: 'creditCode',
				type: 'input',
				span: 6,
			},
			{
				label: '机构名称',
				prop: 'organizationName',
				type: 'input',
				span: 6,
			},
			{
				label: '联系方式',
				prop: 'organizationPhone',
				type: 'input',
				span: 6,
			},
			{
				label: '所属地区',
				propName: 'areas_name',
				type: 'AplidAreaSelect',
				span: 6,
			},
			{
				label: '联系人',
				prop: 'deputyUserName',
				type: 'input',
				span: 6,
			},
			{
				label: '申报年月',
				prop: 'fillingDateBetween',
				type: 'daterange',
				format: 'YYYY年MM月DD日',
				valueFormat: 'YYYY-MM-DD',
				span: 12,
			},
		],
	},
	detailConfig,
	tableConfig,
	importConfig,
	beforeOnLoadFormate: async (params) => {
		params = toSearchHandle(moreSearchConfig,{},params)

		// if(params.fillingDateBetween){
		// 	params.fillingDateBetween = params.fillingDateBetween.join(',')
		// }else{
		// 	params.fillingDateBetween = undefined
		// }
		// 将搜索数据改为id和区划名
		let areasName = getAreaObj(params.areas_name, 'belong')
		return Promise.resolve({
			...params,
			...areasName,
			areas_name: undefined,
		})
	},
	onLoadFormate: async (arr) => {
		console.log('列表', arr)
		const tableData = arr.map((item) => {
			let areas_name = getAreaObj(item, 'belong')
			return {
				...item,
				areas_name,
			}
		})

		return Promise.resolve(Object.freeze(tableData))
	},
}
